<template>
  <div class="area">
    <div class="bg">
      <div class="content">
        <div class="th">全国风险地区汇总</div>
        <template v-if="highArea.length > 0">
          <div class="title">
            <img src="@/assets/image/high.png" alt="" />
            高风险区{{ highArea.length }}个
          </div>
          <ul class="list">
            <li v-for="(item, index) in highArea" :key="index">
              {{ item }}
            </li>
          </ul>
        </template>
        <!-- 中风险 -->
        <template v-if="midArea.length > 0">
          <div class="title">
            <img src="@/assets/image/mid.png" alt="" />
            中风险区{{ midArea.length }}个
          </div>
          <ul class="list">
            <li v-for="(item, index) in midArea" :key="index">
              {{ item }}
            </li>
          </ul>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import api from '@/api/index.js'
export default {
  data () {
    return {
      highArea: [], // 高风险区数据
      midArea: [] // 低风险区域
    }
  },
  created () {
    api.getCovInfo().then((res) => {
      console.log(res.data.newslist[0])
      const riskarea = res.data.newslist[0].riskarea
      // 解析
      this.highArea = riskarea.high
      this.midArea = riskarea.mid
    })
  }
}
</script>

<style lang="less" scoped>
.area {
  background: #f5f5f5;
}
.bg {
  position: relative;
  height: 3.6rem;
  background-color: orange;
  background-size: cover;
  padding-top: 1rem;
}
// .bg:after {
//   content: '全国疫情风险';
//   font-size: 0.5rem;
//   font-weight: bold;
//   color: #fff;
//   position: absolute;
//   top: 1rem;
//   left: 50%;
//   transform: translateX(-50%);
// }
.content {
  background: #fff;
  margin-left: 0.2rem;
  margin-right: 0.2rem;
  padding: 0.2rem;
  border-radius: 0.2rem;
  min-height: 4rem;
  margin-bottom: 0.2rem;
  .th {
    margin-bottom: 0.3rem;
    font-size: 0.34rem;
  }
  .th:before {
    display: inline-block;
    width: 0.1rem;
    height: 0.3rem;
    margin-right: 0.1rem;
    background-color: #4169e2;
    content: '';
    vertical-align: middle;
  }
  .title {
    font-size: 0.3rem;
    margin-bottom: 0.3rem;
    img {
      width: 0.4rem;
      vertical-align: top;
    }
  }
  .list {
    li {
      margin-bottom: 0.2rem;
      color: #333;
      background: #f7f7f7;
      padding: 0.1rem;
      border-radius: 0.1rem;
      letter-spacing: 0.01rem;
      line-height: 0.5rem;
    }
  }
}
</style>
